/*
 * GF_C_MODEL_STRING_LIKE_LIST_20240913/EXAMPLES/EXAMPLES_STRING_LIKE_LIST_EXTRACT_ELEMENT_BY_INDEX.c
 * Created by GF on 2024/09/13.
 */

#include <stdio.h>
#include <string.h> /* memset(); strcmp(); strcpy(); strlen(); strtok();*/
#include <malloc.h> /* malloc(); */
#include "../GF_C_MODEL_STRING_LIKE_LIST.h"

/* free(); */

int main(int argc, char *argv[]) {

    char Example_String_1[3]  = "[]";
    char Example_String_2[10] = "[A,B,C,D]";
    char Example_String_3[13] = "[1, 2, 3, 4]";
    
    char* Result;
    
    printf("**************************************************\n");
    printf("Examples (STRING_LIKE_LIST_EXTRACT_ELEMENT_BY_INDEX):\n");
    Result = STRING_LIKE_LIST_EXTRACT_ELEMENT_BY_INDEX(Example_String_1,  0);
    printf("Expect: \"[]\"           => \"(NULL)\" | Output: %s\n", Result);
    Result = STRING_LIKE_LIST_EXTRACT_ELEMENT_BY_INDEX(Example_String_2,  2);
    printf("Expect: \"[A,B,C,D]\"    => \"C\"      | Output: %s\n", Result);
    Result = STRING_LIKE_LIST_EXTRACT_ELEMENT_BY_INDEX(Example_String_3, -2);
    printf("Expect: \"[1, 2, 3, 4]\" => \"3\"      | Output: %s\n", Result);
    
    free(Result);

    return 0;
}
